<?php
require_once('include/inc_database.php');
require_once('include/inc_useraccount.php');

// Open DB connection.
$dbobj = new DatabaseObject();
$dbobj->OpenConnection();

$username = $_POST['username'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$email = substr($_POST['email'], 0, 100);
if ($_POST['emailNewRecs'] == "on")
	$emailNewRecs = true;
else
	$emailNewRecs = false;
$fullName = substr($_POST['fullName'], 0, 50);
$url = substr($_POST['url'], 0, 100);

// Check for dumb, evil robots.
if ($_POST['robot_detector'] != "abcfed") {
	echo "<p>Error.  Please enable Javascript.";
	exit();
}

// Error check.
if ($password !== $password2) {
	echo "<p>Passwords to not match.  Try retyping.";
	exit();
}

$auth = new UserAccount();
if (!$auth->CreateUser($username, $password)) {
	echo "<p>Error: " . $auth->error_string;
	exit();
}

$dbobj->SendQuery("UPDATE mr_useraccount SET email = " . ValToSQL_str($email) . ", emailNewRecs = " . ValToSQL_bit($emailNewRecs) . ", fullName = " . ValToSQL_str($fullName) . ", url = " . ValToSQL_str($url) . " WHERE username = " . ValToSQL_str($username) . "");
?>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><?=SiteConst('site_name')?></title>

<link rel="shortcut icon" href="images/favicon.gif" type="image/x-icon">
<meta name="viewport" content="width=700"/>

<style type="text/css">

	@import url('rec.css?<?=$CSS_VERSION?>');


</style></head>

<body>

<div id="main">

<h1 style="margin-bottom:25px;">
	<a href="./"><img src="images/logo02b.jpg" align="middle" border="0"/></a>
	Create Account
</h1>

	
<div class="inset_box">
	<img src="images/success_check01.png" align="top"/> User successfully created.  Log in at the <a href="login.php">login page</a>.
</div>



<hr />

<div style="text-align:center;">
	<!--<a href="/news/view.php?newsID=<?=$newsID?>&amp;del=on">help remove inappropriate comments</a>-->
	<br>Return to <a href="./"><?=SiteConst('site_name')?></a>
</div>


</div>


</body>
</html>
